package com.srit.forecast.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.srit.forecast.constant.Constant;

public class FormInterceptor extends HandlerInterceptorAdapter {
	/**
	 * 在Controller方法前进行拦截
	 */
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		System.out
				.println("*********************preHandle********************");
		System.out.println("ControllerInterceptor.preHandle()");
		return true;
	}

	/**
	 * This implementation is empty.
	 */
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		request.setAttribute(Constant.PAGE_TYPE, Constant.PAGE_TYPE_FORM);
		System.out.println("ControllerInterceptor.postHandle()");
	}

	/**
	 * 在Controller方法后进行拦截
	 */
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		System.out.println("ControllerInterceptor.afterCompletion()");
	}

}
